package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.mapper.ReportMapper;
import com.itheima.health.service.ReportServicve;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ReportServicveImpl implements ReportServicve {

    @Autowired
    ReportMapper reportMapper;
    @Override
    public Map memberReportByLastYear() {
        List<Map> mapList = reportMapper.memberReportByLastYear();
        Map map = new HashMap<>();
        List listY = new ArrayList<>();
        List listM= new ArrayList<>();
        for (Map mapL : mapList) {
            Object yearandmonths = mapL.get("yearandmonths");
            listY.add(yearandmonths);
            Object membercounts = mapL.get("membercounts");
            listM.add(membercounts);
        }
        map.put("yearandmonths",listY);
        map.put("membercounts",listM);
        return map;
    }

    @Override
    public List<Map> setmealProportion() {

        return reportMapper.setmealProportion();
    }
}
